﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using ModuleDALCore;
using System.Data;
namespace DAL
{
    public class CONGTYDAO:DALBase
    {
        public CONGTYDAO()
        {
            this.OpenConnect();
        }
        private DataTable dt;
        private string _SpName;

        public string SpName
        {
            get { return "SPCONGTY"; }
            set { _SpName = value; }
        }
        public DataTable GetListCONGTY()
        {
            dt = new DataTable();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new CONGTY(), null), ConvertClassToArray.GetValues(new CONGTY(), 0));
				return dt;
			}
			catch { return null; }
        }
		public List<CONGTY> GetListCONGTYs()
		{
			dt = new DataTable();
			List<CONGTY> ds = new List<CONGTY>();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(new CONGTY(), null), ConvertClassToArray.GetValues(new CONGTY(), 0));
				ds = (List<CONGTY>)ConvertDatatableToList.ConvertTo<CONGTY>(dt);
				return ds;
			}
			catch { return null; }
		}
        public String CreatenewId()
        {
            try
            {
                return "CT" + DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(new CONGTY(), null), ConvertClassToArray.GetValues(new CONGTY(), 1));

            }
			catch { return null; }
        }
        public bool INSERT(CONGTY cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 2)) == 1);

            }
			catch { return false; }
        }
        public bool UPDATE(CONGTY cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 3)) == 1);

            }
			catch { return false; }
        }
        public bool DELETE(CONGTY cv)
        {

            try
            {
                return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 4)) == 1);

            }
			catch { return false; }
        }
    }
}
